1. Field of the Invention
The invention relates to chip cards and, more especially, to cards used as a means of prepayment for the counting down (or counting out) of units as and when goods or services are used. However, the invention is not limited to this use of chip cards: it relates more generally to applications in which units have to be counted up or counted down by means of a programming of non-volatile electrically erasable, programmable memory (EEPROM) cells.
2. Description of the Prior Art
In microprocessor-based chip cards, which are also called asynchronous cards, the counting methods are efficient, adaptable to the application and protected against fraud or operating errors. However, in cards without microprocessors or in synchronous cards (which have the advantage of being less costly), the methods are less versatile and less sure.
The principle of the counting, which today appears to be the principle best suited to synchronous cards, is the abacus principle which makes it possible, with a small number of EEPROM cells, to count out a large number of units. The advantage of this principle is that it is easy to make and hence that its cost is not excessively high.
In abacus-type counting, the memory is organized into N zones of P cells, in practice N rows of P cells. The number of cells programmed in a row is a figure representing the number of units memorized and the rank or order number of the row represents the weight of this figure. The weight assigned to a row is P times the weight of the immediately lower ranking or lower order row. The total count of units is the sum of the numbers of cells programmed in each row, these numbers being weighted by the weight of the respective row.
For example, with a memory of three rows of eight cells each, respectively having x cells, y cells and z cells on the first, second and third row having respective weights of 8.sup.0, 8.sup.1 and 8.sup.2, namely 1, 8 and 64, the total count of units represented by the memory is: x+8y+64z. This 24-cell memory can count up from 0 to 584 units and count down from 584 to 0.
By convention, it is assumed here below that the erased cell is represented by a logic "1" and that the programmed cell is represented by a logic "0", and it will therefore be assumed that the memory to count the units down from an initial total rather than count them up by incrementing this total. The reverse would of course be obtained by the use of reverse conventions.
Let it be assumed, for example, returning to the example of a memory with three rows of eight cells, that the initial count is 194 (expressed in terms of a decimal number), i.e. z=3, y=0, x=2.
The initial pattern of the memory is:
______________________________________ 11100000 z = 3 3 .times. 64 = 192 00000000 y = 0 +0 .times. 8 = 0 11000000 x = 2 +2 .times. 1 = 2 Total: 194 ______________________________________
The countdown by one unit will consist in programming an erased cell of the last row at zero, taking x to 1 and taking the count to 191; to make a countdown by yet another unit, another cell of the last row is programmed, taking x to 0 and the count to 192.
The pattern of the 24 cells of the memory then becomes:
______________________________________ 11100000 00000000 00000000 count : 192 ______________________________________
Here the problem becomes more difficult since it is no longer possible to program cells with a unit weight.
Consequently, there is prepared an intermediate sequence that is proper to abacus-type counting and consists, in this example, of:
a. the programming, at 0, of a cell at 1 of the first row (in fact, the first cell at 1 that is encountered in making a trace-back from the last row to the first row; here it is a cell of the first row since there are none in the second): the pattern becomes:
______________________________________ 11000000 00000000 00000000 ______________________________________
b. the erasing of the entire second row (i.e. the erasing of the entire row that follows a row in which a programming is done); the pattern becomes:
______________________________________ 11000000 11111111 00000000 the count is truly 192 as before. ______________________________________
However, it is not always possible to make a unit-by-unit countdown since there is no erased cell on the lightweight row; then the same sequence as above, i.e. a followed by b, is carried out again:
a'. the programming, at 0, of the first cell at 1 encountered in making a trace-back from the last row to the first row; the pattern becomes:
______________________________________ 11000000 11111110 00000000 ______________________________________
b'. the erasing of the entire row that follows the row in which a programming has just been done; the pattern becomes:
______________________________________ 11000000 11111110 11111111 the count is still 192. ______________________________________
However, it is now possible to make a unit-by-unit countdown by the successive programming of the cells of the row with the lightest weight.
The principle of the countdown by one unit therefore consists in carrying out the following recurrent procedure: making a search in the memory, by going through it in the rising order of weights, for an erased cell (at 1), programming this cell (putting it at 0) and, if it does not belong to the row with the lightest weight, erasing (placing at 1) the entire row of an immediately lower rank and recommencing the procedure.
However, it has been observed that this recurrent procedure, while it is fairly simple, could have drawbacks: if the intermediate patterns of the memory during the steps a and a' of the recurrence are looked at again, it is seen that the account contained in the memory at the end of these steps is respectively 128 and 184 whereas it ought to be 192 since these steps are only intermediate steps performed when there has not yet been any counting down by one unit.
Consequently if, by chance, the current should be cut off during these steps, for example by the wrenching of the card out of its reader, then the memory will keep an erroneous account which bears no relation whatsoever to the real account.
It will be understood that, in certain applications, this may have major drawbacks. This is so, for example, if the account in the memory represents an available credit for the bearer: a portion of this credit will be permanently lost. In other applications, the opposite could be the case. In any case, this situation is not desirable.
The invention is aimed at overcoming this drawback.